﻿$(function () {
    $('#divCode').slideVerify({
        type: 1,		//类型
        vOffset: 5,	//误差量，根据需求自行调整
        barSize: {
            width: '100%',
            height: '35px',
        },
        ready: function () {
        },
        success: function () {
            VMRegister.loginInfo.lgnCode = true;
        },
        error: function () {
            //		        	alert('验证失败！');
        }
    });
})
var VMRegister = new Vue({
    el: "#divRegister",
    data: {
        loginInfo: {
            lgnName: "",
            lgnPwd: "",
            lgnNewPwd: "",
            lgnTelCode: "",
            qq: "",
            lgnCode: false
        }
    },
    methods: {
        RegisterUser: function () {
            if (this.loginInfo.lgnName == "") {
                this.$message({
                    message: '用户名不能为空！',
                    type: 'warning'
                });
                return;
            }
            if (this.loginInfo.lgnTelCode == "") {
                this.$message({
                    message: '请输入验证码！',
                    type: 'warning'
                });
                return;
            }
            if (this.loginInfo.lgnTelCode == "") {
                this.$message({
                    message: '密码不能为空！',
                    type: 'warning'
                });
                return;
            }
            if (this.loginInfo.lgnPwd == "") {
                this.$message({
                    message: '密码不能为空！',
                    type: 'warning'
                });
                return;
            }
            if (this.loginInfo.lgnPwd != this.loginInfo.lgnNewPwd) {
                this.$message({
                    message: '两次密码不一致！',
                    type: 'warning'
                });
                return;
            }
            if (!this.loginInfo.lgnCode) {
                this.$message({
                    message: '请滑动验证！',
                    type: 'warning'
                });
                return;
            }
            $.post("/Account/RegisterUser", this.loginInfo, function (data) {
                if (data.suc) {
                    VMRegister.$message({
                        message: data.msg,
                        type: 'success'
                    });
                    setTimeout(function () {
                        location.href = "/account/login";
                    }, 200);
                }
                else {
                    VMRegister.$message.error(data.msg);
                }
            })
        }
    },
    mounted: function () {

    }
});
